package com.nm.web.convert;

import com.nm.commons.util.StringUtil;
import com.nm.orm.dao.pageParam.ArticleBackPageInput;
import com.nm.orm.dao.pageParam.ArticlePageInput;
import com.nm.orm.pojo.ArticleEntity;
import com.nm.web.request.ArticleBackPageRequest;
import com.nm.web.request.ArticlePageRequest;
import com.nm.web.request.ArticleUpdateRequest;

/**
 * Created by hewu on 2017/2/15 0015.
 */
public class ArticleConvertor {

    public static ArticlePageInput conv(ArticlePageRequest request) {

        ArticlePageInput out = new ArticlePageInput();
        out.setCategoryId(request.getCategoryId());
        out.setLabelId(request.getLabelId());
        out.setPage(request.getPage());
        out.setRows(request.getRows());

        return out;
    }

    public static ArticleBackPageInput conv(ArticleBackPageRequest request) {
        ArticleBackPageInput out = new ArticleBackPageInput();
        out.setCategoryId(StringUtil.isNull(request.getCategoryId()) ? null : request.getCategoryId());
        out.setLabelId(StringUtil.isNull(request.getLabelId()) ? null : request.getLabelId());
        out.setPage(request.getPage());
        out.setRows(request.getRows());

        return out;

    }

    public static ArticleEntity conv(ArticleUpdateRequest request) {
        ArticleEntity out = new ArticleEntity();
        out.setId(request.getId());
        out.setContent(request.getContent());
        out.setName(request.getName());

        return null;
    }
}
